﻿// -----------------------------------------------------------------------
// <copyright file="Action.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Ex04.Menus.Delegates
{
    using System;
    using System.Collections.Generic;
    using System.Text;

   /// <summary>
   /// Deceleration of class delegate
   /// </summary>
    public delegate void PerformTheActionDelegate();
    
    /// <summary>
    /// This class is one of the two options that you can choose to do in the program.
    /// Here he is getting the action it self in delegate.
    /// </summary>
    public class Action : MenuItem
    {
        public PerformTheActionDelegate m_PerformAction;

        /// <summary>
        /// Constructor of the action that gets the content of the action
        /// </summary>
        /// <param name="i_NameAction">
        /// Getting from the name of the action for indication to the user
        /// </param>
        /// <param name="i_PerformAction">
        /// This is the content of the action that the user of this function need to create
        /// </param>   
        public Action(string i_NameAction, PerformTheActionDelegate i_PerformAction) : base(i_NameAction)
        {
            this.m_PerformAction = i_PerformAction;
        }

        internal override void DoSomething()
        {
            Console.Clear();
            if (this.m_PerformAction != null)
            {
                this.m_PerformAction.Invoke();
            }
        }
    }
}
